//
//  SupermarketStellTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/5.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "SupermarketStellTableViewCell.h"

@interface SupermarketStellTableViewCell ()
@property (nonatomic,strong) GLGWImageView * leftImageView;
@property (nonatomic,strong) GLGWLabel * stellNamelabel;
@property (nonatomic,strong) GLGWLabel * specLabel;
@property (nonatomic,strong) GLGWLabel * warehoseLabel;
@property (nonatomic,strong) GLGWButton * comapnyNameBut;

@property (nonatomic,strong) GLGWLabel * storeNameLabel;
@property (nonatomic,strong) GLGWLabel * piceLabel;

@end

@implementation SupermarketStellTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        [bankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
        }];
        //
        self.leftImageView = [[GLGWImageView alloc] initInSuperView:bankgroundView];
        self.leftImageView.backgroundColor = kRandomColor;
        [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(15));
            make.bottom.equalTo(bankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(15));
            if (self.accountType == AccountType_Ordinary) {
                make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(82)));
            }else{
                make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(90)));
            }
        }];
        
        //
        self.stellNamelabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:bankgroundView];
        [self.stellNamelabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.leftImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            if (self.accountType == AccountType_Ordinary) {
                make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(20));
            }else{
                make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            }
            make.right.equalTo(bankgroundView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        //
        self.warehoseLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        [self.warehoseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.stellNamelabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(8));
        }];
        //
        self.specLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
        [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stellNamelabel);
            make.top.equalTo(self.stellNamelabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
            make.right.equalTo(self.warehoseLabel.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(5));
        }];
        //
        self.piceLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:bankgroundView];
        self.piceLabel.text = @"¥455元/吨";
        //
        if (self.accountType == AccountType_FreeManagers) {
            self.comapnyNameBut = [[GLGWButton alloc] initWithTitleLableFontType:SYSTEMFONT(12) titleColor:kColor_Rule_Yellow inSuperView:bankgroundView];
            [self.comapnyNameBut mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.stellNamelabel);
                make.top.equalTo(self.specLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
            }];
            NSMutableDictionary *attribtDic = [NSMutableDictionary dictionary];
            attribtDic[NSUnderlineStyleAttributeName] = [NSNumber numberWithInteger:NSUnderlineStyleSingle];
            attribtDic[NSForegroundColorAttributeName] = kColor_Rule_Yellow;
            NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:@"北京泽人合有限公司" attributes:attribtDic];
            [self.comapnyNameBut setAttributedTitle:attribtStr forState:UIControlStateNormal];
            //
            GLGWButton * syncBut = [[GLGWButton alloc] initWithTitle:@"同步到店铺" titleLableFont:SYSTEMFONT(12) titleLableColor:[UIColor whiteColor] theCornerRadius:3.0 backgroundColr:kColor_Rule_Yellow inSuperView:bankgroundView];
            [syncBut mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(10));
                make.bottom.equalTo(bankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
                make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(70)));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(25)));
            }];
            //
            [self.piceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.comapnyNameBut);
                make.top.equalTo(self.comapnyNameBut.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
            }];
        }else{
            self.piceLabel.textAlignment = NSTextAlignmentRight;
            [self.piceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.equalTo(bankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(20));
                make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
            }];
            //
            GLGWButton * inStoreBut = [[GLGWButton alloc] initWithTitle:@"进店" titleLableFont:SYSTEMFONT(12) titleLableColor:kColor_Rule_Yellow inSuperView:bankgroundView];
            inStoreBut.image_Name = @"icon_jindian";
            [inStoreBut setImagePositionWithType:SSImagePositionTypeRight spacing:0];
            [inStoreBut mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.piceLabel.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(10));
                make.top.equalTo(self.specLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
                make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
            }];
            [inStoreBut addTarget:self action:@selector(chickStore) forControlEvents:UIControlEventTouchUpInside];
            //
            self.storeNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
            [self.storeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.specLabel);
                make.top.height.equalTo(inStoreBut);
                make.right.equalTo(inStoreBut.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(10));
            }];
        }
    }
    return self;
}

-(void)setStell_inforModel:(SupermarketStellModel_Infos *)stell_inforModel{
    _stell_inforModel = stell_inforModel;
    self.stellNamelabel.text = [NSString stringWithFormat:@"%@  %@  %@",koString(_stell_inforModel.productsSeller.productName),koString(_stell_inforModel.productsSeller.productMaterial),koString(_stell_inforModel.productsSeller.factoryName)];
    //
    self.specLabel.text = _stell_inforModel.productsSeller.specifications;
    //
    self.warehoseLabel.text = _stell_inforModel.productsSeller.storehouseName;
    //
    self.piceLabel.text = [NSString stringWithFormat:@"¥%.2f/吨",_stell_inforModel.price];
    //
    self.storeNameLabel.text = _stell_inforModel.shopName;
    
}

-(void)chickStore{
    if (self.Block_InStore) {
        self.Block_InStore();
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
